package com.app.base.utlis.verification;

import java.util.Random;

/**
 * 随机生成验证码
 * @author run
 * @date 2022/05/04
 */
public class CodeUtils {


    /**
     * 随机生成六位验证码
     * @return {@link String}
     */
    public static String code(){
        String str="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789";
        Random random=new Random();
        StringBuilder sb=new StringBuilder();
        for(int i=0;i<6;i++){
            int number=random.nextInt(62);
            sb.append(str.charAt(number));
        }
        return sb.toString();
    }

}
